<%@ page language="java" contentType="text/html; charset=utf-8"	pageEncoding="utf-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   <title></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<%@include file="/common/common_header.jsp"%>
  	<link href="${ctx}/static/css/base.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/static/css/default.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="${ctx}/static/js/echarts.js"></script>
</head>
<body>    

	<div id="chart" style="width:100%;height:100%;"></div>
	<script type="text/javascript">
	$(function(){
		 //ajax调用
        $.ajax({
            type: "post",
            dataType: "json",
            url:  _global_web_app_path+"/stock_info_chart/chart_data_num",
            error: function (e) {
                $.messager.alert('错误', e.responseText, 'error');
            },
            success: function (data) {
           	   // 基于准备好的dom，初始化echarts实例
                var myChart = echarts.init(document.getElementById('chart'));
				
           	   var name_array=[];
           	   var count_array=[];
           	   
             for(i=0;i<data.length;i++){
            	 name_array.push(data[i].merchandise_name);
            	 count_array.push(parseInt(data[i].num));
               }
           	   
                // 指定图表的配置项和数据
                var option = {
                    title: {
                        text: '库存商品数量统计分析图',
                        x:'center'
                    },
                    tooltip: {},
                    legend: {
                        data:['库存数量']
                    },
                    xAxis: {
                        data: name_array
                    },
                    yAxis: {},
                    series: [{
                        name: '数量',
                        type: 'bar',
                        data: count_array
                    }]
                };

                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);            	
            }
        });
		
	});
	 
	</script>    
</body>
</html>